home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / util / threads / threadpool2.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  41 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from threadpool import ThreadPool, WorkRequest
  5. from functools import wraps
  6. from util.callbacks import callsback
  7. from util.introspect import funcinfo
  8. from logging import getLogger
  9. log = getLogger('threadpool2')
  10.  
  11. def threaded(func):
  12.     
  13.     def wrapper(*a, **kws):
  14.         callback = kws.pop('callback')
  15.         requestID = kws.pop('requestID', None)
  16.         req = WorkRequest(func, args = a, kwds = kws, requestID = requestID, callback = callback.success, exc_callback = callback.error)
  17.         req.verbose = wrapper.verbose
  18.         t = ThreadPool()
  19.         t.putRequest(req)
  20.  
  21.     wrapper = None((wraps(func), callsback)(wrapper))
  22.     wrapper.verbose = True
  23.     return wrapper
  24.  
  25.  
  26. def threadedonce(func):
  27.     
  28.     def wrapper(*a, **kws):
  29.         t = ThreadPool()
  30.         if func in t:
  31.             log.warning('%s is already running in the ThreadPool, not running', funcinfo(func))
  32.         else:
  33.             callback = kws.pop('callback')
  34.             requestID = kws.pop('requestID', None)
  35.             req = WorkRequest(func, args = a, kwds = kws, requestID = requestID, callback = callback.success, exc_callback = callback.error)
  36.             t.putRequest(req)
  37.  
  38.     wrapper = wraps(func)((callsback,)(wrapper))
  39.     return wrapper
  40.  
  41.